package team.archai.nexus.flow.listener;

import cn.hutool.extra.spring.SpringUtil;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import team.archai.nexus.flow.service.IProcessManage;

/**
 * 默认流程任务监听
 *
 * @author li shi bin
 */
public class DefaultTaskListener implements TaskListener {
    @Override
    public void notify(DelegateTask delegateTask) {
        String eventName = delegateTask.getEventName();
        IProcessManage processManage = SpringUtil.getBean(IProcessManage.class);
        //任务创建
        switch (eventName) {
            case EVENTNAME_CREATE:
                processManage.onCreate(delegateTask);
                break;
            case EVENTNAME_ASSIGNMENT:
                processManage.onAssignment(delegateTask);
                break;
            case EVENTNAME_COMPLETE:
                processManage.onComplete(delegateTask);
                break;
            case EVENTNAME_DELETE:
                processManage.onDelete(delegateTask);
                break;
            default:
                break;
        }
    }
}
